<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>主页</title>
</head>
<style>
    table{
        margin-top: 5px;
        border-style:solid;
        flex: content;
    }
</style>
<body>
    <div>
        <input type="text" placeholder="查找博客标题、摘要、内容、分类、作者" name="keyword">
        <input type="button" value="查找" onclick="query()">
        <input type="button" value="添加" onclick="add()">
    </div>
    <!-- 1、js可以操作dom节点
    2、js可以请求网络数据 -->
    <table id="rowdate">
        <tr>
            <th>Id</th>
            <th>标题</th>
            <th>摘要</th>
            <th>内容</th>
            <th>分类</th>
            <th>作者</th>
            <th>操作</th>
        </tr>
        <tr class="rowdata">
            <td>1</td>
            <td>1</td>
            <td>1</td>
            <td>1</td>
            <td>1</td>
            <td>1</td>
            <td>
                <input type="button" value="编辑" onclick="update()">
                <input type="button" value="删除" onclick="del()">
            </td>
        </tr>
    </table>

    <script src="./js/jquery-3.6.0.min.js"></script>
    <script src="./config/baseUrl.js"></script>
    <script src="./js/init.js"></script>
    <script src="./js/app.js"></script>
    <script>
        //修改
        function update(id) {
            location.href = `./Createedit.html?id=` + id;
        }
        //删除
        function del(id) {
            asdelete(id).then(data => {
                console.log('----------');
                if (data.code === 1000) {
                    let id = data.data.id;
                    $(`[key=${id}]`).remove();
                    alert('删除成功！')
                    location.href = './index.html'
                } else {
                    alert(data.msg);
                }
            })
        }
        //查找
        function query() {
            let keyword = $('[name=keyword]').val();
            keywords(keyword);
        }
    </script>
</body>

</html>